#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
typedef pair<int, int> Coin;
int N, C;
vector<Coin> vcs;
int used[25];
int solve();
int main() {
    scanf("%d %d", &N, &C);
    int c, n;
    while (N--) {
        scanf("%d %d", &c, &n);
        vcs.push_back({-c, n});
    }
    printf("%d\n", solve());
}

int solve() {
    // 采用的思路是逐个的遍历取
    int res = 0;
    sort(vcs.begin(), vcs.end());
    while (true) {
        memset(used, 0, sizeof used);
        int pay = C;
        // 这是为了看能不能凑整
        for (int i = 0; i < vcs.size(); i++) {
            int num = min(vcs[i].second, pay / -vcs[i].first);
            pay += num * vcs[i].first;
            used[i] = num;
        }

        // 这是看能不能凑多
        if (pay) {
            for (int i = vcs.size() - 1; i >= 0; i--) {
                if (-vcs[i].first >= pay && vcs[i].second) {
                    pay = 0;
                    used[i] += 1;
                    break;
                }
            }
        }
        
        // 东拼西凑之后看能不能凑齐
        if (pay) break;
        // 可以凑齐, 记录方案之后减
        int minx = 1 << 30;
        for (int i = 0; i < vcs.size(); i++) {
            if (used[i]) minx = min(minx, vcs[i].second / used[i]); // 记录数目
        }
        for (int i = 0; i < vcs.size(); i++) {
            if (used[i]) vcs[i].second -= used[i] * minx;
        }
        res += minx;
    }
    return res;
}